package com.ebelter.seneo.ui.activitys;


import android.content.Intent;
import android.text.TextUtils;
import android.view.View;

import com.ebelter.btcomlib.models.db.products.seneo.SeneoUserinfos;
import com.ebelter.btcomlib.utils.UserSpUtil;
import com.ebelter.seneo.R;
import com.ebelter.seneo.contants.IUserContant;
import com.ebelter.seneo.models.SeneoDbUtils;

public class SeneoWelcomeActivity extends SeneoBaseActivity {


    @Override
    protected int loadLayoutById() {
        return R.layout.activity_seneo_welcome;
    }


    @Override
    protected void initData() {
        String name = UserSpUtil.readString(IUserContant.IUser.loginName);
        String psw =UserSpUtil.readString(IUserContant.IUser.psw);
        String psw2 =UserSpUtil.readString(IUserContant.IUser.psw);
        SeneoUserinfos host = SeneoDbUtils.getHostUserinfos();

        if (!TextUtils.isEmpty(name)&&!TextUtils.isEmpty(psw)&&!TextUtils.isEmpty(psw2)&&host!=null){
            //说明已经登录过了
            SeneoMainActivity.openSeneoMainActivity(this,true);
            finish();
            return;
        }


        boolean isfirst = UserSpUtil.readBoolean("isfirst",true);//是否第一次打开app

        if (!isfirst){
            startActivity(new Intent(this,SeneoLoginActivity.class));
            finish();
        }

    }

    public void login(View view) {
        UserSpUtil.writeBoolean("isfirst",false);
        startActivity(new Intent(this,SeneoLoginActivity.class));
    }

    public void register(View view) {
       // startActivity(new Intent(this,SeneoRegisterActivity.class));
        UserSpUtil.writeBoolean("isfirst",false);
        SeneoAddInfoActivity.openSeneoAddInfoActivity(this,1002,SeneoAddInfoActivity.CMD_register,"Register",0);
    }


}
